package com.yan.deezer.network;

import org.apache.http.client.methods.HttpGet;


public class RequestBuilder {

	private static final String TAG							= "RequestBuilder";
	
	private static final String ROOT_URL 					= "http://api.deezer.com/2.0/";
	
	private static final String REQUEST_ACTION_SEARCH_TRACKS		= "search?q=";
	private static final String REQUEST_ACTION_SEARCH_ARTISTS		= "search/artist?q=";
	private static final String REQUEST_ACTION_SEARCH_ALBUMS		= "search/album?q=";
	private static final String REQUEST_ACTION_GET_ARTIST		= "artist/";
	private static final String REQUEST_ACTION_GET_ALBUMS="/albums";
	//artist/27/albums

	
	private static StringBuffer rootQuery(){
		return new StringBuffer().append(ROOT_URL);
	}
	
	private static StringBuffer basicQuery(String action){
		StringBuffer query = rootQuery();

		query.append(action);
		return query;
	}
	


	public static HttpGet getTracksQuery(String userInput){
		StringBuffer query = basicQuery(REQUEST_ACTION_SEARCH_TRACKS);
		query.append(userInput);
		return getHttpRequest(query.toString());
	}

	
	public static HttpGet getAlbumsQuery(String userInput){
		StringBuffer query = basicQuery(REQUEST_ACTION_SEARCH_ALBUMS);
		query.append(userInput);
		return getHttpRequest(query.toString());
	}

	
	public static HttpGet getArtistsQuery(String userInput){
		StringBuffer query = basicQuery(REQUEST_ACTION_SEARCH_ARTISTS);
		query.append(userInput);
		return getHttpRequest(query.toString());
	}
	
	public static HttpGet getArtistQuery(String artistID){
		StringBuffer query = basicQuery(REQUEST_ACTION_GET_ARTIST);
		query.append(artistID);
		return getHttpRequest(query.toString());
	}

	
	public static HttpGet getArtistAlbumsQuery(String artistID){
		StringBuffer query = basicQuery(REQUEST_ACTION_GET_ARTIST);
		query.append(artistID).append(REQUEST_ACTION_GET_ALBUMS);
		return getHttpRequest(query.toString());
	}



	private static HttpGet getHttpRequest (String url) {
    	HttpGet request = new HttpGet(url);

		return request;
	 }
	

}